package com.chen.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.chen.entity.ExamPaper;
import com.chen.vo.ExamPaperVO;
import com.chen.vo.PapersDataVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 试卷Mapper
 */
public interface ExamPaperMapper extends BaseMapper<ExamPaper> {

    /**
     * 总试卷数量
     *
     * @return
     */
    default Long findAllCount() {
        return selectCount(Wrappers.lambdaQuery(ExamPaper.class));
    }

    /**
     * 根据年级获取试卷个数
     * @param gradeId
     * @return
     */
    default Long findCountByGradeId(Integer gradeId) {
        Wrapper<ExamPaper> queryWrapper = Wrappers.lambdaQuery(ExamPaper.class).eq(ExamPaper::getGradeId, gradeId);
        return selectCount(queryWrapper);
    }

    /**
     * 分页列表查询
     * @param gradeId
     * @param index
     * @param pageShow
     * @return
     */
    List<ExamPaperVO> listPage(@Param("gradeId") Integer gradeId, @Param("index") Integer index, @Param("pageShow") Integer pageShow);

    public List<ExamPaperVO> findAll();

    ExamPaperVO findById(Integer id);

    /**
     * 修改添加试卷分数
     * @param id
     * @param score
     * @return
     */
    Integer addScoreById(@Param("id") Integer id, @Param("score") Integer score);

    /**
     * 试卷答题统计
     * @param teacherId
     * @return
     */
    public List<PapersDataVO> getExamPapersData(@Param("teacherId") Integer teacherId);
}
